/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   for_test.c
 * Author: james
 *
 * Created on March 14, 2018, 1:01 PM
 */

#include <stdio.h>

/*
 * print Fahrenheit-Celsius table
 * From zero to three hundrad, each 20 to print out the map between the two;
 */
// Method 1:

/*
int main(int argc, char** argv) {

    int fahr;
    float cels;

    for (fahr = 0; fahr <= 300; fahr = fahr + 20) {
        cels = (5.0 / 9.0) * (fahr - 32);
        printf("%3d %6.1f\n", fahr, cels);
    }
}*/

// Method 2:
int main() {
    int fahr;

    for (fahr = 0; fahr <= 300; fahr = fahr + 20)
        printf("%3d %6.1f\n", fahr, (5.0 / 9.0)*(fahr - 32));
}


/*
%6.1f - means : print as floating point, 
                at least 6 wide and 1 after decimal point.
%3d - means : print as decimal integer, at least 3 characters wide.
*/

/*
 This program will output as:
  0  -17.8  // See, there will have 3 characters wide.
 20   -6.7
 40    4.4
 60   15.6
 80   26.7
100   37.8
120   48.9
140   60.0
160   71.1
180   82.2
200   93.3
220  104.4
240  115.6
260  126.7
280  137.8
300  148.9

 */